<?php

namespace app\api\controller\question;

use app\api\controller\Controller;
use app\api\model\question\Questionnaire;
use app\api\model\question\Questionnaire as Model;
use app\api\model\question\Topic;

class Index extends Controller
{
//    public function getPracticeList($application_id)
//    {
//        $model = new Model;
//        $list = $model->getPracticeList($application_id);
//        return $this->renderSuccess(compact('list'));
//    }
//
//    public function recordLeam($application_id)
//    {
//        $model = new Model;
//        $accumulate_learn = $model->recordLeam($application_id);
//        return $this->renderSuccess(compact('accumulate_learn'));
//    }

    public function getObtainPracticeQuestions($student_sign_id,$questionnaire_id)
    {
//        $sign = (new \app\api\model\student\Sign)
//            ->field('student_sign_id,job_id,job_level,questionnaire_id')
//            ->where([
//                'student_sign_id' => $student_sign_id,
//                'is_delete' => 0
//            ])->find();
//        if (!$sign) {
//            return $this->renderError('学员信息不存在！');
//        }
        $questionnaire_info = (new Questionnaire())
            ->field('questionnaire_id,answering_time,passing_mark')
            ->where([
                'questionnaire_id' => $questionnaire_id,
                'is_delete' => 0,
                'status' => 0
            ])
            ->find();
        if (!$questionnaire_info) {
            return $this->renderError('问卷不存在！');
        }

        $list = (new Topic())->getPracticeList($questionnaire_id);

        return $this->renderSuccess(compact('list'));
    }
}
